//
//  WUTaskVCell.m
//  Home
//
//  Created by 吴军虎吴军虎 on 16/6/2.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "WUTaskCell.h"

@interface WUTaskCell ()

@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong)  UILabel *nameL;
@property (nonatomic, strong)  UILabel *xinL;
@property (nonatomic, strong)  UILabel *yanjingL;
@property (nonatomic, strong)  UILabel *zhanshiL;
@property (nonatomic, strong)  UILabel *zhongL;
@property (nonatomic, strong)  UILabel *editlabel;
@property (nonatomic, strong)  UILabel *delete;


@end

@implementation WUTaskCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubView];
    }
    
    return self;
}

- (void)createSubView
{
    _myImageView = [UIImageView new];
    _myImageView.image = [UIImage imageNamed:@"u=957005295,3708602591&fm=206&gp=0.jpg"];
    [self.myBackWhiteView addSubview:_myImageView];
    [_myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self).offset(40/2 *AUTO_HEIGHT);
        make.left.equalTo(self).offset(30/2 *AUTO_WIDTH);
        make.right.equalTo(self).offset(-30/2 *AUTO_WIDTH);
        make.height.mas_offset(340/2 *AUTO_HEIGHT);
    }];
    
    
    _nameL = [UILabel new];
    _nameL.text = @"湖滨花园";
    _nameL.textColor = GH;
    _nameL.font = [UIFont fontWithName:TFont size:LOGINFONT * AUTO_WIDTH];
    [self.myBackWhiteView addSubview:_nameL];
    [_nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_myImageView.mas_bottom).offset(18/2 *AUTO_HEIGHT);
        make.left.equalTo(self).offset(45/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(140/2 *AUTO_WIDTH, 40/2 *AUTO_HEIGHT));
    }];
    
    
    
    UIImageView *xin = [UIImageView new];
    xin.image = [UIImage imageNamed:@"qiang2x"];
    [self.myBackWhiteView addSubview:xin];
    [xin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15 *AUTO_WIDTH, 15 * AUTO_HEIGHT));
        make.left.mas_equalTo(_nameL.mas_right).offset(10 * AUTO_WIDTH);
        make.top.mas_equalTo(_myImageView.mas_bottom).offset(23/2 * AUTO_HEIGHT);
        
        
    }];
    
    _xinL = [UILabel new];
    [self.myBackWhiteView addSubview:_xinL
     ];
    _xinL.text = @"30";
    _xinL.textColor = ZI;
    _xinL.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [_xinL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(xin);
        make.left.mas_equalTo(xin.mas_right).offset(12/3 * AUTO_WIDTH);
        make.height.mas_equalTo(xin);
        
    }];
    
    
    
    UIImageView *yangjingIV = [UIImageView new];
    [self.myBackWhiteView addSubview:yangjingIV];
    yangjingIV.image = [UIImage imageNamed:@"mi"];
    [yangjingIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(xin).offset(1.5 * AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(18 *AUTO_WIDTH, 13 * AUTO_HEIGHT));
        make.left.mas_equalTo(_xinL.mas_right).offset(30/3 * AUTO_WIDTH);
        
    }];
    
    
    
    _yanjingL  = [UILabel new];
    [self.myBackWhiteView addSubview:_yanjingL];
    _yanjingL.text = @"110";
    _yanjingL.textColor = ZI;
    _yanjingL.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [_yanjingL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_xinL);
        make.left.mas_equalTo(yangjingIV.mas_right).offset(12/3 * AUTO_WIDTH);
        make.height.mas_equalTo(_xinL);
        
    }];
    
    
    
    UIImageView *zanshiIV = [UIImageView new];
    [self.myBackWhiteView addSubview:zanshiIV];
    zanshiIV.image = [UIImage imageNamed:@"fangwu"];
    [zanshiIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(xin);
        make.left.mas_equalTo(_yanjingL.mas_right).offset(30/3 * AUTO_WIDTH);
        make.top.mas_equalTo(xin);
        
    }];
    
    _zhanshiL = [UILabel new];
    [self.myBackWhiteView addSubview:_zhanshiL];
    _zhanshiL.text = @"平层户型";
    _zhanshiL.textColor = ZI;
    _zhanshiL.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [_zhanshiL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_xinL);
        make.left.mas_equalTo(zanshiIV.mas_right).offset(12/3 * AUTO_WIDTH);
        make.height.mas_equalTo(_xinL);
        
    }];
    
    UIImageView *diImage = [UIImageView new];
    [self.myBackWhiteView addSubview:diImage];
    diImage.image = [UIImage imageNamed:@"fenge"];
    [diImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(xin);
        make.left.mas_equalTo(_zhanshiL.mas_right).offset(30/3 * AUTO_WIDTH);
        make.top.mas_equalTo(xin);
        
    }];
    
    _zhongL = [UILabel new];
    [self.myBackWhiteView addSubview:_zhongL];
    _zhongL.text = @"地中海";
    _zhongL.textColor = ZI;
    _zhongL.font = [UIFont fontWithName:TFont size:TEXTLABELFONT * AUTO_WIDTH];
    [_zhongL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_xinL);
        make.left.mas_equalTo(diImage.mas_right).offset(12/3 * AUTO_WIDTH);
        make.height.mas_equalTo(_xinL);
        
    }];
    
    
    UIImageView *lim = [UIImageView new];
    [self.myBackWhiteView addSubview:lim];
    lim.image = [UIImage imageNamed:@"虚线"];
    [lim mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).offset(0);
        make.top.equalTo(_myImageView.mas_bottom).offset(70/2 *AUTO_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(1000/2 *AUTO_WIDTH, 1 * AUTO_HEIGHT));
        
    }];
    
    
    UIView *editView=[[UIView alloc]init];
    editView.userInteractionEnabled=YES;
    UITapGestureRecognizer *edittap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(editAction:)];
    [editView addGestureRecognizer:edittap];
    editView.tag=1000;
    [self.myBackWhiteView addSubview:editView];
    [editView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lim.mas_bottom).offset(14/2 *AUTO_HEIGHT);
        make.right.equalTo(self).offset(-150/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(88/2 *AUTO_WIDTH, 26/2 *AUTO_HEIGHT));
    }];
    
    
    
    UIImageView *banImage=[[UIImageView alloc]init];
    banImage.image=[UIImage imageNamed:@"ban"];
    [editView addSubview:banImage];
    [banImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(editView).offset(0);
        make.left.equalTo(editView).offset(0);
        make.size.mas_equalTo(CGSizeMake(26/2 *AUTO_WIDTH, 26/2 *AUTO_HEIGHT));
    }];
    
    _editlabel=[[UILabel alloc]init];
    _editlabel.text=@"编辑";
    _editlabel.textColor = ZI;
    _editlabel.font = [UIFont fontWithName:TFont size:TEXTALITTLEFONT * AUTO_WIDTH];
    [editView addSubview:_editlabel];
    [_editlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(editView).offset(4/2 *AUTO_HEIGHT);
        make.left.equalTo(banImage.mas_right).offset(12/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(50/2 *AUTO_WIDTH, 20/2 *AUTO_HEIGHT));
    }];
    
    
    UIView *deleteView=[[UIView alloc]init];
    deleteView.userInteractionEnabled=YES;
    UITapGestureRecognizer *deletap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(banAction:)];
    [deleteView addGestureRecognizer:deletap];
    deleteView.tag=1001;
    [self.myBackWhiteView addSubview:deleteView];
    [deleteView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lim.mas_bottom).offset(14/2 *AUTO_HEIGHT);
        make.left.equalTo(editView.mas_right).offset(35/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(88/2 *AUTO_WIDTH, 26/2 *AUTO_HEIGHT));
        
    }];
    
    
    UIImageView *chuImage=[[UIImageView alloc]init];
    chuImage.image=[UIImage imageNamed:@"chu"];
    [deleteView addSubview:chuImage];
    [chuImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(deleteView).offset(0);
        make.left.equalTo(deleteView).offset(0);
        make.size.mas_equalTo(CGSizeMake(26/2 *AUTO_WIDTH, 26/2 *AUTO_HEIGHT));
    }];
    
    
    _delete=[[UILabel alloc]init];
    _delete.text=@"删除";
    _delete.textColor=ZI;
    _delete.font=[UIFont fontWithName:TFont size:TEXTALITTLEFONT * AUTO_WIDTH];
    [deleteView addSubview:_delete];
    [_delete mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(deleteView).offset(4/2 *AUTO_HEIGHT);
        make.left.equalTo(chuImage.mas_right).offset(12/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(50/2 *AUTO_WIDTH, 20/2 *AUTO_HEIGHT));
        
    }];
}


-(void) banAction:(UITapGestureRecognizer *) tap
{
    
    _delete.textColor=[UIColor redColor];
    [self.delegate  taskViewCell:2];
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(NBeee) userInfo:nil repeats:NO];
}

-(void) editAction:(UITapGestureRecognizer *) tap
{
    _editlabel.textColor = [UIColor redColor];
    
    [self.delegate  taskViewCell:1];
    
    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(NBeee) userInfo:nil repeats:NO];
    
}
-(void)NBeee{
    
    _editlabel.textColor=ZI;
    _delete.textColor=ZI;
    
}
-(void)settingModel:(ResignModel *)model{
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",HTTPURL,model.indeximg]] placeholderImage:nil];
    NSLog(@"sssss=%@",[NSString stringWithFormat:@"%@%@",JIAFANURL,model.indeximg]);
    _nameL.text = model.title;
    _xinL.text = model.money;
    _yanjingL.text = model.mianji;
    _zhanshiL.text = model.huxing;
    _zhongL.text = model.style;
    
    
    
    
}

@end
